// source --> http://rozumeni.cz/wp-content/plugins/photo-gallery/js/bwg_frontend.js?ver=1.4.12 var bwg_param; jQuery(document).ready(function () { bwg_document_ready(); jQuery(".bwg-thumbnails").each(function () { bwg_all_thumnails_loaded(this); }); }); jQuery(window).on("resize", function () { jQuery(".bwg-thumbnails").each(function () { bwg_all_thumnails_loaded(this); }); }); function bwg_all_thumnails_loaded(that) { var thumbnails_count = 0; var thumbnails_loaded = jQuery(that).find("img").length; jQuery(that).find("img").each(function () { var fakeSrc = jQuery(this).attr("src"); jQuery("").attr("src", fakeSrc).on("load error", function() { if ( ++thumbnails_count >= thumbnails_loaded ) { bwg_thumbnail(that); } }); }); } function bwg_container_loaded(bwg) { jQuery('#gal_front_form_' + bwg).removeClass('bwg-hidden'); jQuery('#ajax_loading_' + bwg).addClass('bwg-hidden'); } function bwg_thumbnail(that) { var container_width = jQuery(that).width(); var thumb_width = jQuery(that).data("thumbnail-width"); var max_count = jQuery(that).data("max-count"); var column_count = parseInt(container_width / thumb_width) + 1; if (column_count > max_count) { column_count = max_count; } /*var flex = 1 / column_count;*/ var min_width = 100 / column_count; var bwg_item = jQuery(that).find(".bwg-item"); bwg_item.css({ /*flexGrow: flex,*/ width: min_width + "%" }); jQuery(that).children(".bwg-item").each(function () { var image = jQuery(this).find("img"); var item2 = jQuery(this).find(".bwg-item2"); if ( (item2.width() / item2.height()) > (image.width() / image.height()) ) { if ( item2.width() > image.width() ) { image.css({width: "100%"}); } else { image.css({maxWidth: "100%"}); } } else { if ( item2.height() > image.height() ) { image.css({height: "100%"}); } else { image.css({maxHeight: "100%"}); } } jQuery(this).find(".bwg-item2").css({ marginLeft: (item2.width() - image.width()) / 2, marginTop: (item2.height() - image.height()) / 2 }); }); bwg_container_loaded(jQuery(that).data('bwg')); } function bwg_document_ready() { var bwg_touch_flag = false; jQuery( ".bwg_lightbox .bwg-item0, .bwg_lightbox .bwg_slide" ).on( "click", function ( event ) { event.stopPropagation(); event.preventDefault(); var that = jQuery(this).parent(); if ( !bwg_touch_flag ) { bwg_touch_flag = true; setTimeout( function () { bwg_touch_flag = false; }, 100 ); bwg_gallery_box( jQuery( that ).attr( "data-image-id" ), jQuery( that ).closest( '.bwg_container' ) ); return false; } } ); jQuery( ".bwg_lightbox .bwg_ecommerce" ).on( "click", function ( event ) { event.stopPropagation(); if ( !bwg_touch_flag ) { bwg_touch_flag = true; setTimeout( function () { bwg_touch_flag = false; }, 100 ); var image_id = jQuery( this ).closest( ".bwg_lightbox" ).attr( "data-image-id" ); bwg_gallery_box( image_id, jQuery( this ).closest( '.bwg_container' ), true ); return false; } } ); jQuery( 'div[id^="bwg_container"]' ).each( function () { var bwg_container = jQuery( this ); if ( bwg_container.data( 'right-click-protection' ) ) { /* Disable right click.*/ bwg_container.bind( "contextmenu", function () { return false; } ); bwg_container.css( 'webkitTouchCallout', 'none' ); } var search_tags = bwg_container.find('.search_tags'); if (search_tags.length) { search_tags.SumoSelect( { placeholder: bwg_objectsL10n.bwg_select_tag, search: 1, searchText: bwg_objectsL10n.bwg_search, forceCustomRendering: true } ); } } ); var bwg_hash = window.location.hash.substring( 1 ); if ( bwg_hash ) { if ( bwg_hash.indexOf( "bwg" ) != "-1" ) { bwg_hash_array = bwg_hash.replace( "bwg", "" ).split( "/" ); var bwg_container = jQuery( '.bwg_container[data-gallery-id=' + bwg_hash_array[0] + ']' ); if ( bwg_container ) { bwg_gallery_box( bwg_hash_array[1], bwg_container ); } } } } function bwg_clear_search_input (current_view) { jQuery("#bwg_search_input_" + current_view).val(''); } function bwg_check_search_input_enter(that, e) { var key_code = e.which || e.keyCode; if (key_code == 13) { jQuery(that).closest('.bwg_search_container_1').find('.bwg_search').trigger('click'); return false; } return true; } function bwg_gallery_box(image_id, bwg_container, openEcommerce) { if(typeof openEcommerce == undefined){ openEcommerce = false; } var bwg = bwg_container.data('bwg'); var bwg_lightbox_url = bwg_container.data('lightbox-url'); var filterTags = jQuery("#bwg_tags_id_bwg_standart_thumbnails_" + bwg ).val(); filterTags = filterTags ? filterTags : 0; var ecommerce = openEcommerce == true ? "&open_ecommerce=1" : ""; var filtersearchname = jQuery("#bwg_search_input_" + bwg ).val(); filtersearchname = filtersearchname ? filtersearchname : ''; spider_createpopup(bwg_lightbox_url + '&image_id=' + image_id + "&filter_tag=" + filterTags + ecommerce + '&filter_search_name=' + filtersearchname, bwg, bwg_container.data('popup-width'), bwg_container.data('popup-height'), 1, 'testpopup', 5, bwg_container.data('buttons-position')); } function spider_frontend_ajax(form_id, current_view, id, album_gallery_id, cur_album_id, type, srch_btn, title, sortByParam, load_more, description) { jQuery(window).off("scroll"); var masonry_loaded = 0; var mosaic_loaded = 0; if (typeof load_more == "undefined") { var load_more = false; } var page_number = jQuery("#page_number_" + current_view).val(); var bwg_load_more = jQuery("#bwg_load_more_" + current_view).val(); var bwg_previous_album_ids = jQuery('#bwg_previous_album_id_' + current_view).val(); var bwg_previous_album_page_numbers = jQuery('#bwg_previous_album_page_number_' + current_view).val(); var post_data = {}; if (album_gallery_id == 'back') { // Back from album. var bwg_previous_album_id = bwg_previous_album_ids.split(","); album_gallery_id = bwg_previous_album_id[1]; jQuery('#bwg_previous_album_id_' + current_view).val(bwg_previous_album_ids.replace(bwg_previous_album_id[0] + ',', '')); var bwg_previous_album_page_number = bwg_previous_album_page_numbers.split(","); page_number = bwg_previous_album_page_number[0]; jQuery('#bwg_previous_album_page_number_' + current_view).val(bwg_previous_album_page_numbers.replace(bwg_previous_album_page_number[0] + ',', '')); post_data["action_" + current_view] = 'back'; } else if (cur_album_id != '') { // Enter album (not change the page). jQuery('#bwg_previous_album_id_' + current_view).val(album_gallery_id + ',' + bwg_previous_album_ids); if (page_number) { jQuery('#bwg_previous_album_page_number_' + current_view).val(page_number + ',' + bwg_previous_album_page_numbers); } page_number = 1; } if (srch_btn) { // Start search. page_number = 1; } if (typeof title == "undefined" || title == '') { var title = ""; } if (typeof description == "undefined" || description == '') { var description = ""; } if (typeof sortByParam == "undefined" || sortByParam == '') { var sortByParam = jQuery(".bwg_order_" + current_view).val(); } post_data["page_number_" + current_view] = page_number; post_data["bwg_load_more_" + current_view] = bwg_load_more; post_data["album_gallery_id_" + current_view] = album_gallery_id; post_data["bwg_previous_album_id_" + current_view] = jQuery('#bwg_previous_album_id_' + current_view).val(); post_data["bwg_previous_album_page_number_" + current_view] = jQuery('#bwg_previous_album_page_number_' + current_view).val(); post_data["type_" + current_view] = type; post_data["title_" + current_view] = title; post_data["description_" + current_view] = description; post_data["sortImagesByValue_" + current_view] = sortByParam; if (jQuery("#bwg_search_input_" + current_view).length > 0) { // Search box exists. post_data["bwg_search_" + current_view] = jQuery("#bwg_search_input_" + current_view).val(); } post_data["bwg_tag_id_" + id] = jQuery("#bwg_tag_id_" + id).val(); // Loading. if ( id != "bwg_standart_thumbnails_" + current_view ) { jQuery("#ajax_loading_" + current_view).css('display', ''); } else { jQuery("#ajax_loading_" + current_view).removeClass('bwg-hidden'); } jQuery.ajax({ type: "POST", url: window.location, data: post_data, success: function (data) { masonry_loaded = jQuery(data).find('#' + form_id).find(".bwg_masonry_thumb_spun_" + current_view + " img").length; mosaic_loaded = jQuery(data).find('#' + form_id).find(".bwg_mosaic_thumb_spun_" + current_view + " img").length; if (load_more) { var strr = jQuery(data).find('#' + id).html(); jQuery('#' + id).append(strr); jQuery("div[id^='bwg_container1_'] form").each(function () { if (jQuery(this).data("current") == current_view) { var str = jQuery(data).find('.bwg_nav_cont_' + current_view).html(); jQuery('.bwg_nav_cont_' + current_view).html(str); } else { var str = jQuery(this).find('span[class^="bwg_nav_cont_"]').html(); jQuery(this).find('span[class^="bwg_nav_cont_"]').html(str); } }); } else { var str = jQuery(data).find('#' + form_id).html(); jQuery('#' + form_id).html(str); } // There are no images. if (jQuery("#bwg_search_input_" + current_view).length > 0 && album_gallery_id == 0) { // Search box exists and not album view. var bwg_images_count = jQuery('#bwg_images_count_' + current_view).val(); if (bwg_images_count == 0) { var cont = jQuery("#" + id).parent().html(); var error_msg = '
' + bwg_objectL10n.bwg_search_result + '